<!-- 公共文件 start -->
@extends('admin.public.base')
<!-- 公共文件 end -->
<style>
    table th {
        min-width: 10px !important;
    }
    .layui-card-header {
        padding-top: 10px !important;
    }
</style>
@section('content')
    <div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">财务报表</a>
        <a><cite>商品台账</cite></a>
    </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" autocomplete="off" placeholder="开始时间" name="start" id="start" value="{{request()->input('start')}}">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" autocomplete="off" placeholder="截止时间" name="end" id="end" value="{{request()->input('end')}}">
                            </div>
                            <div class="layui-inline layui-show-xs-block" id="goods_id">
                                <div id="goods_id_select"></div>
                                <input type="hidden" id="goods_id_select_value" value="{{request()->input('goods_id_select')}}">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button id="search" class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;搜索</i>
                                </button>
                                <input type="hidden" id="export_excel" name="export_excel" value="0">
                                <button id="export_excel_btn" class="layui-btn" lay-submit="" lay-filter="sreach"><i
                                        class="layui-icon">&#xe65b;</i>导出Excel
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body ">
                        <table class="layui-table layui-form" style="width: 100%">
                            <thead>
                            <tr>
                                <th>日期</th>
                                <th>年</th>
                                <th>月</th>
                                <th>日</th>
                                <th>单号</th>
                                <th>类型</th>
                                <th>购货单位</th>
                                <th>商品编号</th>
                                <th>商品名称</th>
                                <th>商品规格</th>
                                <th>商品单位</th>
                                <th>商品价格</th>
                                <th>数量</th>
                            </thead>
                            <tbody>
                            @foreach($data as $item)
                                <tr>
                                    <td>
                                        {{$item['date']}}
                                    </td>
                                    <td>
                                        {{$item['year']}}
                                    </td>
                                    <td>
                                        {{$item['month']}}
                                    </td>
                                    <td>
                                        {{$item['day']}}
                                    </td>
                                    <td>
                                        {{$item['order_sn']}}
                                    </td>
                                    <td>
                                        @if($item['type'] == 1)
                                            <span style="color: #009688">出库</span>
                                        @else
                                            <span style="color: #FF5722">入库</span>
                                        @endif
                                    </td>
                                    <td>
                                        @if($item['type'] == 2)
                                            ENC
                                        @else
                                            {{$item['store_name']}}
                                        @endif
                                    </td>
                                    <td>
                                        {{$item['goods_sn']}}
                                    </td>
                                    <td>
                                        {{$item['goods_name']}}
                                    </td>
                                    <td>
                                        {{$item['goods_specification']}}
                                    </td>
                                    <td>
                                        {{$item['goods_unit']}}
                                    </td>
                                    <td>
                                        @if($item['is_give'] == 1)
                                            {{$item['goods_price']}} <span style="color: red">（赠送）</span>
                                        @else
                                            {{$item['goods_price']}}
                                        @endif
                                    </td>
                                    <td>
                                        {{$item['goods_number']}}
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{ $data->links('admin/public/page') }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.config({
            base: './'
        }).extend({
            selectM: '../../static/admin/lib/layui/layui_extends/selectM',
        }).use(['laydate', 'form', 'selectM'], function(){
            form = layui.form, laydate = layui.laydate,selectM = layui.selectM;

            var goods_id_selected_item = $("#goods_id_select_value").val().split(",");
            //多选标签-商品
            var tagIns1 = selectM({
                //元素容器【必填】
                elem: '#goods_id_select',
                data: '/admin/goods/goodsList/json',
                max: 26,
                width: 260,
                tips: '请选择商品',
                selected: goods_id_selected_item
                //添加验证
                // ,verify:'required'
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#start', //指定元素
                type: 'datetime'
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end', //指定元素
                type: 'datetime'
            });
        });

        $("#export_excel_btn").on('click', function () {
            layer.load(2, {
                time: 10000
            });
            $("#export_excel").val(1)
        });
        $("#search").on('click', function () {
            layer.load(2, {
                time: 10000
            });
            $("#export_excel").val(0);
        });
    </script>
@endsection
